package com.xuhai.blog.api;

import com.xuhai.blog.admin.entity.CommentEntity;
import com.xuhai.blog.admin.service.CommentService;
import com.xuhai.blog.common.util.ResultJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Author PangJunjie
 * @Date 2022/2/19/019
 */
@RestController
@RequestMapping("/api/comment")
public class ApiCommentController {
    @Autowired
    private CommentService commentService;

    @PostMapping("/save")
    public ResultJson save(@RequestBody CommentEntity comment){
        comment.setCommentTime(new Date());
        commentService.save(comment);
        return ResultJson.ok();
    }
}
